﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Program05
{
    class Healthy
    {
        /// <summary>
        /// 是否健康
        /// </summary>
        /// <param name="sex">性别</param>
        /// <param name="height">身高</param>
        /// <param name="weight">体重</param>
        /// <returns></returns>
        public string isHealthy(bool sex, float height, float weight)
        {
            //男性标准体重
            float maleFlagWeight = ((height - 80) * 0.7f);

            //女性标准体重
            float feMaleFlagWeight = ((height - 70) * 0.6f);

            //逻辑判断
            if (sex == true)
            {
                if ((weight - maleFlagWeight) / maleFlagWeight > 0)
                {
                    if ((weight - maleFlagWeight) / maleFlagWeight > 0.2f)
                    {
                        return "肥胖,该减肥了";
                    }
                    else if ((weight - maleFlagWeight) / maleFlagWeight > 0.1f)
                    {
                        return "体重过重,稍微注意";
                    }
                    else
                    {
                        return "体重正常";
                    }
                }
                else if ((weight - maleFlagWeight) / maleFlagWeight < 0)
                {
                    if (MathF.Abs((weight - maleFlagWeight) / maleFlagWeight) > 0.2f)
                    {
                        return "体重不足,多吃东西";
                    }
                    else if (MathF.Abs((weight - maleFlagWeight)) / maleFlagWeight > 0.1f)
                    {
                        return "体重过轻,稍微注意";
                    }
                    else
                    {
                        return "体重正常";
                    }
                }
                else
                {
                    return "体重正常";
                }


            }
            else if (sex == false)
            {
                if ((weight - feMaleFlagWeight) / feMaleFlagWeight > 0)
                {
                    if ((weight - feMaleFlagWeight) / feMaleFlagWeight > 0.2f)
                    {
                        return "肥胖,该减肥了";
                    }
                    else if ((weight - feMaleFlagWeight) / feMaleFlagWeight > 0.1f)
                    {
                        return "体重过重,稍微注意";
                    }
                    else
                    {
                        return "体重正常";
                    }
                }
                else if ((weight - feMaleFlagWeight) / feMaleFlagWeight < 0)
                {
                    if (MathF.Abs((weight - feMaleFlagWeight) / feMaleFlagWeight) > 0.2f)
                    {
                        return "体重不足,多吃东西";
                    }
                    else if (MathF.Abs((weight - feMaleFlagWeight)) / feMaleFlagWeight > 0.1f)
                    {
                        return "体重过轻,稍微注意";
                    }
                    else
                    {
                        return "体重正常";
                    }
                }
                else
                {
                    return "体重正常";
                }
            }
            else
            {
                return "???人妖???";
            }
        }
    }
}
